<template>
	<view>
		<u-navbar back-text="" back-icon-color="#333333" :border-bottom="false" title-color="#333333" title="金蜜券" :background="background"></u-navbar>
		<view class="top">
			<view class="up">
				<view class="left">
					<view class="number">
						{{jindoujuan}}
					</view>
					<view class="text">
						剩余总数
					</view>
				</view>
				<view class="right">
					<view class="list" v-if="false" @click="toPage('exchange')">
						<image src="../static/jindou0.png" mode=""></image>
						<view class="name">
							派发
						</view>
					</view>
					<view class="list" @click="toPage('exchange-list')">
						<image src="../static/jindou1.png" mode=""></image>
						<view class="name">
							兑换申请
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="content">
			<view class="title">
				明细
			</view>
			<view v-if="list.length>0">
				<view class="list" v-for="(item,index) in list" :key="index">
					<image src="../static/jindou2.png" class="head"></image>
					<view class="view">
						<view class="name">
							{{item.name}}
						</view>
						<view class="telphone">
							{{item.time}}
						</view>
					</view>
					<view :class="item.flag=='IN'?'number add':'number sub'">
						{{item.flag=='IN'?'+':'-'}}{{item.change}}
					</view>
				</view>
			</view>
			<view class="none" v-else>
				<view class="none-view">
					<image src="../../../static/image/none.png" class="none-image"></image>
					<view class="none-name">
						暂无相关数据~
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	var than;
	export default {
		data() {
			return {
				background: {
					'background': '#E5EDFC'
				},
				list: [],
				jindoujuan: "",
				page: 1
			}
		},

		onLoad(option) {
			than = this;
			than.getList()
			than.post("api/Teamhead/gdbTicketNumber", null, function(data) {
				than.jindoujuan = data.jindoujuan;
			})
		},
		onReachBottom() {
			than.page++;
			than.getList()
		},
		onShow() {},
		methods: {
			getList() {
				than.post("api/teamhead/useList", {
					page: than.page
				}, function(data) {
					for (let i in data) {
						var d = data[i]
						switch (d.type) {
							case 'MANUAL_CHANGE_ADMIN':
								d.name = "后台派发"
								break;
							case 'EXCHANGE_GDB_TICKET':
								d.name = "兑换金蜜券"
								break;
							case 'EXCHANGE_GDB_GOODS':
								d.name = "兑换蜂巢"
								break;
							case 'HAND_OUT_GDB_TICKET':
								d.name = "派发金蜜券"
								break;
							case 'ADMIN_HAND_OUT_GDB_TICKET':
								d.name = "兑换金蜜券"
								break;
							default:
								d.name = "未知"
								break;
						}
					}
					if (than.page == 1) {
						than.list = data;
					} else {
						than.list = than.list.concat(data)
					}
				})
			}
		}
	}
</script>

<style lang="less">
	.top {
		height: 300rpx;
		background: #E5EDFC;
		padding: 0 36rpx;

		.up {
			display: flex;
			align-items: center;
			height: 220rpx;
			width: 100%;

			.left {
				.number {
					font-size: 84rpx;
					font-family: DIN Medium;
					font-weight: 400;
					color: #333333;
				}

				.text {
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
				}
			}

			.right {
				display: flex;
				align-items: center;
				margin-left: auto;

				.list {
					text-align: center;
					margin-left: 45rpx;

					image {
						width: 78rpx;
						height: 78rpx;
					}

					.name {
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #333333;
					}
				}
			}
		}


	}

	.content {
		background: #F4F4F7;
		border-radius: 70rpx 0px 0px 0px;
		margin-top: -80rpx;
		position: relative;
		z-index: 1;
		padding: 0 36rpx;

		.title {
			height: 106rpx;
			line-height: 106rpx;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
		}

		.list {
			padding: 0 24rpx;
			margin-bottom: 24rpx;
			height: 150rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			display: flex;
			align-items: center;

			.head {
				width: 99rpx;
				height: 99rpx;
			}

			.view {
				margin-left: 35rpx;

				.name {
					margin-right: 10rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #333333;
					margin-bottom: 20rpx;
				}

				.telphone {
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
			}

			.number {
				margin-left: auto;
				font-size: 40rpx;
				font-family: DINCond-Black;
				font-weight: bold;

			}

			.add {
				color: #F46813;
			}

			.sub {
				color: #1B1B1D;
			}

		}
	}

	page {
		background: #F4F4F7;
	}
</style>
